package com.wish.common.core.usconfig.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @ClassName MsgResult
 * @Description TODO
 * @Author 18516
 * @DATE 2022/1/10 10:12:59
 * @Version 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MsgResult implements Serializable {

    //    接口是否正常响应
    private Boolean flag;
    //    接口返回结果状态码
    private Integer code;
    //    接口信息提示
    private String msgInfo;
    //    接口错误数据
    private Object msgData;

    /**
     * 正常消息返回
     */
    public static MsgResult succeed() {
        return new MsgResult(true, 200, null, null);
    }

    public static MsgResult succeed(Object data) {
        return new MsgResult(true, 200, null, data);
    }

    /**
     * 错误响应
     */
    public static MsgResult fail() {
        return new MsgResult(false, 500, null, null);
    }

    public static MsgResult fail(Integer errCode, String message, Object errData) {
        return new MsgResult(false, errCode, message, errData);
    }


}
